<template>
  <div class="big">
    <Commonhead datum="我的关注" @click.native="back"></Commonhead>
    <div>
      <div class="attention" v-for="user in follwlist" :key="user.id">
        <div class="imges">
          <img
            v-if="user.head_img"
            :src="'http://157.122.54.189:9083' + user.head_img"
            alt=""
          />
          <img v-else src="../../assets/2.jpg" alt="" />
        </div>
        <div class="topic">
          <p>{{ user.nickname }}</p>
          <span>2020-01-01</span>
        </div>
        <div class="btn" @click="cancel(user.id)">
          <p>取消关注</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 引入子组件

import Commonhead from "@/components/Commonhead";

export default {
  components: { Commonhead },
  data() {
    return {
      follwlist: [],
    };
  },
  created() {
    this.loadPage();
  },
  methods: {
    back() {
      this.$router.push("/mycenter");
    },
    loadPage() {
      this.$axios({
        url: "user_follows",
        headers: { Authorization: localStorage.getItem("token") },
      }).then((res) => {
        console.log(res.data);
        // 显示数据
        this.follwlist = res.data.data;
      });
    },
    cancel(userId) {
      this.$axios({
        url: "user_unfollow/" + userId,
        headers: { Authorization: localStorage.getItem("token") },
      }).then((res) => {
        console.log(res.data);
        this.loadPage();
        // 显示数据
      });
    },
  },
};
</script>

<style lang="less" scoped>
.big {
  min-height: 100vh;
  background-color: #f2f2f2;
}
* {
  margin: 0;
  padding: 0;
}

a {
  color: inherit;
}

a:hover {
  text-decoration: none;
}

ul,
li,
ol {
  list-style: none;
}
.attention {
  padding: 20/360 * 100vw 0;
  border-bottom: #d7d7d7 solid 2px;
  font-size: 14px;
  display: flex;
  align-items: center;
  .imges {
    // display: flex;
    // flex-direction: column;
    // align-items: center;
    margin-left: 23/360 * 100vw;
    img {
      border-radius: 50%;
      height: 40/360 * 100vw;
      width: 40/360 * 100vw;
    }
  }
  .topic {
    padding-bottom: 5/360 * 100vw;
    padding-left: 15/360 * 100vw;
    p {
      padding-bottom: 5/360 * 100vw;
      font-size: 16px;
      font-weight: 700;
    }
    flex: 1;
  }
  .btn {
    width: 70/360 * 100vw;
    height: 30/360 * 100vw;
    background-color: #e1e1e1;
    border-radius: 20px;
    text-align: center;
    line-height: 30/360 * 100vw;
    color: #363636;
    margin-right: 15/360 * 100vw;
  }
}
</style>